<template>
	<view class="content box-shadow">
		<view class="flex flex-column" style="padding: 40upx;">
			<view class="flex-1" style="margin-top: 100upx;">
				<view class="flex flex-row" style="line-height: 70upx; height: 70upx;text-align: left;">
					<view style="width: 100upx;">
						<text style="font-size: 30upx;color: #333333;">手机号:</text>
					</view>
					<view class="flex-1">
						<input class="input-border" v-model="phone" type="number" placeholder="请输入手机号" />
					</view>
					<view style="width: 50upx;text-align: center; height: 70upx;line-height: 70upx;" v-if="phone.length>0" @tap="clearPhone">
						<image style="width: 30upx; height: 30upx;" src="../../static/close.png" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<view class="flex-1" style="margin-top: 20upx;">
				<view class="flex flex-row" style=" line-height: 70upx; height: 70upx;text-align: left;">
					<view style="width: 100upx;">
						<text style="font-size: 30upx;color: #333333;">验证码:</text>
					</view>
					<view class="flex-1">
						<input class="input-border" v-model="checkNum" type="number" placeholder="请输入验证码" />
					</view>
					<view style="width: 200upx;height: 70upx;line-height: 70upx;text-align: center;" :class="{disable:count>0}" @click="sendCode">
							<text style="background-color: #F8F8F8;color: #333333; font-size: 30upx;color: #333333;margin-left: 20upx;padding: 10upx;">{{time()}}</text>
					</view>
				</view>
			</view>
			<view class="flex-1" style="margin-top: 20upx;">
				<view class="flex flex-row" style=" line-height: 70upx; height: 70upx;text-align: left;">
					<view style="width: 100upx;">
						<text style="font-size: 30upx;color: #333333;">新密码:</text>
					</view>
					<view class="flex-1">
						<input class="input-border" v-model="checkPassword"
						 type="password" placeholder="请再次输入密码" />
					</view>
					<view style="width: 50upx;text-align: center; height: 70upx;line-height: 70upx;" v-if="checkPassword.length>0"
					 @tap="clearCheckPassword">
						<image style="width: 30upx; height: 30upx;" src="../../static/close.png" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<view style="flex:1;margin-top: 300upx;">
				<button type="primary">注册</button>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				count: false,
				phone: '',
				checkNum: '',
				account: '',
				password: '',
				checkPassword: ''
			}
		},
		onLoad() {

		},
		methods: {
			sendCode() {// 获取验证码动画
				if (this.count > 0) {
					return false;
				}
				this.count = 59;
				var that = this;
				var timerInterval = setInterval(function() {
					if (that.count > 0) {
						that.count--;
					} else {
						clearInterval(timerInterval);
					}
				}, 1000);
			},
			time() {
				if (this.count > 0) {
					return this.count + 's后获取';
				}
				if (this.count === 0) {
					return '重新获取';
				}
				if (this.count === false) {
					return '获取验证码';
				}
			},
			clearPhone() {
				this.phone = ''
			},
			clearPassword() {
				this.password = ''
			},
			clearCheckPassword() {
				this.checkPassword = ''
			}
		}
	}
</script>

<style>
	.content {
		border: 1upx solid #F8F8F8;
		margin: 180upx 30upx;
		background-color: #FFFFFF;
	}

	.logo {
		height: 180upx;
		width: 180upx;
	}

	.flex {
		display: flex;
	}

	.flex-1 {
		flex: 1;
	}

	.flex-column {
		flex-direction: column;
	}

	.flex-row {
		flex-direction: row;
	}

	.box-shadow {
		box-shadow: 4upx 4upx 10upx rgba(0, 0, 0, 0.2);
	}
	.input-border {
		border: 1upx solid #999999;
		min-height: 60upx;
	}
</style>
